<?php 
session_cache_expire(999999999);
if(!isset($_SESSION)) 
{ 
	session_start(); 
}
$lang = $_SESSION['lang'];
if (empty($lang) || $lang == "EN") {
	include "../value/value_en.php";
} else if($lang == "VN") {
	include "../value/value_vn.php";
}
else {
	include "../value/value_kr.php";
}

$mang1=$_SESSION['listCategory'];
$listmang=array();$max=1;
foreach ($mang1 as $value => $giatri){
	if($max<$giatri[0])
		$max=$giatri[0];
	$listmang[]=array($giatri[0],$giatri[1],$giatri[2],$giatri[3],$giatri[4],$giatri[5],$giatri[6]);
}
$d=date("Y-m-d");
$listmang[]=array($max+1,"",$d,1,0,0,0);
$mang1=$listmang;
$_SESSION['listCategory']=$mang1;
?>
<input id="countmang1" name="countmang1" value='<?=count($mang1)?>'  type="hidden" />
<table cellpadding="0" cellspacing="1" border="0" class="ftable1" style="width: 100%;margin:auto;">
			<tr align='center'>
				<th style="width:10px;"><img onclick="addCategory()" src="images/plus.png" style="width:20px;height:20px;cursor:pointer;" title="<?php echo $l_add;?>" /></th>
				<th><?=$l_pay_category?></th>
				<th style="width: 90px;"><?=$l_pay_dateStart?></th>
				<th style="width: 60px;"><?=$l_pay_regular?></th>
				<th style="width: 60px;"><?=$l_methodsPayment_contract?></th>
				<th style="width: 60px;"><?=$l_payment_money?></th>
			</tr>
			
		<?php 
		$k=1;
		foreach ($mang1 as $value => $giatri){
				if ($giatri[4]==0){
			?>
			<tr align='center'>
				<td><img onclick="delCategory(<?php echo $giatri[0];?>)" src="images/del.png" style="width:20px;height:20px;cursor:pointer;" title="<?php echo $l_delete;?>" /></td>
				<td><input id="idCategory<?=$k?>" name="idCategory[]" value='<?=$giatri[0]?>'  type="hidden"/><input id="nameCategory<?=$k?>" name="nameCategory[]" onchange="chnameCategory(this.value,<?=$giatri[0]?>)" onkeyup="chnameCategory(this.value,<?=$giatri[0]?>)" value='<?=$giatri[1]?>' style="height: 24px;width: 330px;"/></td>
				<td><input id="dateStart<?=$k?>" name="dateStart[]" onchange="chdateStart(this.value,<?=$giatri[0]?>)" onkeyup="chdateStart(this.value,<?=$giatri[0]?>)" value='<?=$giatri[2]?>' style="height: 24px;width: 100px;text-align: center;"/></td>
				<td>
					<select  id="regular<?=$k?>" name="regular[]" onchange="chregular(this.value,<?=$giatri[0]?>)" onkeyup="chregular(this.value,<?=$giatri[0]?>)" style="height: 24px">
						<?php for ($i=1;$i<13;$i++){
							if($giatri[3]==$i){
							?>
						<option value="<?=$i?>" selected="selected"><?=$i?></option>
							<?php }else{?>
						<option value="<?=$i?>"><?=$i?></option>
						<?php }
							}?>
					</select>
				</td>
				<td>
					<select  id="method<?=$k?>" name="method[]" onchange="chmethod(this.value,<?=$giatri[0]?>)" onkeyup="chmethod(this.value,<?=$giatri[0]?>)" style="height: 24px;width: 160px;">
						<?php for ($i=0;$i<=5;$i++){
							$l_method="";
							if($i==0)
								$l_method=$l_method0;
							if($i==1)
								$l_method=$l_method1;
							if($i==2)
								$l_method=$l_method2;
							if($i==3)
								$l_method=$l_method3;
							if($i==4)
								$l_method=$l_method4;
							if($i==5)
								$l_method=$l_method5;
									
							if($giatri[5]==$i){
							?>
						<option value="<?=$i?>" selected="selected"><?=$l_method?></option>
							<?php }else{?>
						<option value="<?=$i?>"><?=$l_method?></option>
						<?php }
							}?>
					</select>
				</td>
				<td><input id="payment<?=$k?>" name="payment[]" onchange="chpayment(this.value,<?=$giatri[0]?>)" onkeyup="chpayment(this.value,<?=$giatri[0]?>)" value='<?=$giatri[6]?>' style="height: 24px;width: 100px;text-align: right; padding-right: 5px"/></td>
			</tr>
		<?php 
				$k++;
				}
		}?>
			
		</table> 